<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>挂号查询</title>
    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">
</head>
<body>


<div class="layuimini-container">

    <div class="layuimini-main">
        <form class="layui-form" action="" style="padding:20px;">
            <div class="layui-form-item">
                <label class="layui-form-label">患者名称:</label>
                <div class="layui-input-inline">
                    <input type="text" name="pname" placeholder="请输入" autocomplete="off" class="layui-input" id="pname" value="1">
                </div>
                <div class="layui-input-inline">
                    <button type="submit" class="layui-btn layui-btn-primary" lay-submit  lay-filter="data-search-ccc"><i class="layui-icon"></i> 搜 索</button>
                </div>
            </div>
        </form>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter">

            <script type="text/html" id="currentTableBar">

            </script>

        </table>
    </div>
</div>

<script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="../../../js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['table', 'form', 'tableSelect'], function () {
        var $ = layui.jquery,
            table = layui.table,
            form = layui.form,
            tableSelect = layui.tableSelect;

    });
</script>
<script>
    function createFormat(o){
        return o;
    }
    layui.use(['table', 'form'], function () {
        //开始使用

        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;


        var userInfo = layui.data('userInfo');

        //加载
        table.render({
            elem: '#currentTableId',
            url: 'http://localhost:8080/hospital/certificate/cers',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[

                {field: 'cid', width: 80, title: 'ID'},

                {templet: '<div>{{createFormat(d.patients.pname)}}</div>', width: 120, title: '患者姓名'},
                {templet: '<div>{{createFormat(d.workers.dname)}}</div>', width: 120, title: '医生姓名'},
                {templet: '<div>{{createFormat(d.department.dtype)}}</div>', width: 120, title: '科室'},
                {templet: '<div>{{createFormat(d.cbc.wbc)}}</div>', width: 80, title: 'wbc'},
                {templet: '<div>{{createFormat(d.cbc.lymphp)}}</div>', width: 80, title: 'lymphp'},
                {templet: '<div>{{createFormat(d.cbc.monop)}}</div>', width: 80, title: 'monop'},
                {templet: '<div>{{createFormat(d.cbc.neutp)}}</div>', width: 80, title: 'neutp'},
                {templet: '<div>{{createFormat(d.cbc.eop)}}</div>', width: 80, title: 'eop'},
                {templet: '<div>{{createFormat(d.cbc.basop)}}</div>', width: 80, title: 'basop'},
                {templet: '<div>{{createFormat(d.cbc.lymph)}}</div>', width: 80, title: 'lymph'},
                {templet: '<div>{{createFormat(d.cbc.mono)}}</div>', width: 80, title: 'mono'},
                {templet: '<div>{{createFormat(d.cbc.neut)}}</div>', width: 80, title: 'neut'},
                {templet: '<div>{{createFormat(d.cbc.eo)}}</div>', width: 80, title: 'eo'},
                {templet: '<div>{{createFormat(d.cbc.baso)}}</div>', width: 80, title: 'baso'},
                {templet: '<div>{{createFormat(d.cbc.rbc)}}</div>', width: 80, title: 'rbc'},
                {templet: '<div>{{createFormat(d.cbc.hgb)}}</div>', width: 80, title: 'hgb'},
                {templet: '<div>{{createFormat(d.cbc.hct)}}</div>', width: 80, title: 'hct'},
                {templet: '<div>{{createFormat(d.cbc.mcv)}}</div>', width: 80, title: 'mcv'},
                {templet: '<div>{{createFormat(d.cbc.mch)}}</div>', width: 80, title: 'mch'},
                {templet: '<div>{{createFormat(d.cbc.mchc)}}</div>', width: 80, title: 'mchc'},
                {templet: '<div>{{createFormat(d.cbc.rdwcv)}}</div>', width: 80, title: 'rdwcv'},
                {templet: '<div>{{createFormat(d.cbc.rdwsd)}}</div>', width: 80, title: 'rdwsd'},
                {templet: '<div>{{createFormat(d.cbc.plt)}}</div>', width: 80, title: 'plt'},
                {templet: '<div>{{createFormat(d.cbc.mpv)}}</div>', width: 80, title: 'mpv'},
                {templet: '<div>{{createFormat(d.cbc.pdw)}}</div>', width: 80, title: 'pdw'},
                {templet: '<div>{{createFormat(d.cbc.plcr)}}</div>', width: 80, title: 'plcr'},
                {field: 'signd', width: 100, title: '征向描述'},
                {field: 'diago', width: 100, title: '诊断意见'},
                {field: 'datec', width: 100, title: '就诊日期'}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            done: function (res, page, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                //分类显示中文名称
                $("[data-field='deleted']").children().each(function () {
                    if ($(this).text() === '0') {
                        $(this).text("正常")
                    } else if ($(this).text() === '1') {
                        $(this).text("不可用")
                    }
                });

            }
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var field = data.field;
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    cdeid: $('#cdeid').val(),
                }//这里传参  向后台
                , url: 'http://localhost:8080/hospital/certificate/searchCerList'
                , method: 'get'
            }, 'data');
            return false;
        });
        form.on('submit(data-search-bbb)', function (data) {
            var field = data.field;

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    cdid: $('#cdid').val(),
                }//这里传参  向后台
                , url: 'http://localhost:8080/hospital/certificate/searchCer'
                , method: 'get'
            }, 'data');

            return false;
        });
        form.on('submit(data-search-ccc)', function (data) {
            var field = data.field;

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    pname: $('#pname').val(),
                }//这里传参  向后台
                , url: 'http://localhost:8080/hospital/certificate/searchCerName'
                , method: 'get'
            }, 'data');

            return false;
        });
        //删除
        table.on('tool(currentTableFilter)', function (obj) {
            if (obj.event === 'del') {
                var data = obj.data;  //得到修改后的值
                $.ajax({
                    url:'http://localhost:8080/hospital/certificate/delCer?cid='+data['cid'],
                    method:'post',
                    data:data.field,
                    dataType:'JSON',
                    success:function(res){
                        if(res.code==='0'){
                            parent.closeIframe("删除成功!");
                        }
                        else
                            alert(res['msg']);
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert("删除失败!");
                    }
                }) ;
                table.reload('currentTableId', {
                }, 'data');
                return false;
            }
        });

        // 监听跳转操作
        $(".data-jump-btn").on("click", function () {

            var index = layer.open({
                title: '全部情况',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/cbc.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

        // 监听添加操作
        $(".data-add-btn").on("click", function () {

            var index = layer.open({
                title: '添加',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/add_cur.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
            return false;
        });

        // 监听修改操作
        $(".data-update-btn").on("click", function () {

            var index = layer.open({
                title: '修改',
                type: 2,
                shade: 0.2,
                maxmin:true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './operation/update_cur.html',
            });
            $(window).on("resize", function () {
                layer.full(index);
            });

            return false;
        });
    });


</script>
</body>
</html>